﻿using System;

namespace reb0x
{
    public class Pattern
    {
        // pattern is always made up of 16 steps		
        public const byte STEPS_PER_PATTERN = 16;

        private Step[] _steps = new Step[STEPS_PER_PATTERN];
        private byte _length = STEPS_PER_PATTERN;

        public Pattern()
        {
        }

        public Step this[uint pos]
        {
            get
            {
                ValidateStepIndex(pos);
                return _steps[pos];
            }

            set
            {
                ValidateStepIndex(pos);
                _steps[pos] = value;
            }
        }

        public Step[] Steps
        {
            get
            {
                return _steps;
            }
        }

        public byte Length
        {
            get { return _length; }
            set { _length = value; }
        }

        private void ValidateStepIndex(uint pos)
        {
            if (pos < 0 || pos >= STEPS_PER_PATTERN)
            {
                throw new IndexOutOfRangeException("Invalid step index");
            }
        }
    }
}
